var express = require('express');
var router = express.Router();
var connection = require('../config')

// get
router.get('/userlist', function(req, res, next) {
    connection.query('SELECT * from users', function (error, results, fields) {
        if (error) throw error;
        res.status(200).send(JSON.stringify(results[0]))
    });
});

// post
router.post('/userAdd', function(req, res, next) {
    console.log(req)
    connection.query('SELECT * from users', function (error, results, fields) {
        if (error) throw error;
        res.status(200).send(JSON.stringify(results[0]))
    });
});

// put
router.put('/userUpdate', function(req, res, next) {
    connection.query('SELECT * from users', function (error, results, fields) {
        if (error) throw error;
        res.status(200).send(JSON.stringify(results[0]))
    });
});

// delete
router.delete('/userDelete', function(req, res, next) {
    connection.query('SELECT * from users', function (error, results, fields) {
        if (error) throw error;
        res.status(200).send(JSON.stringify(results[0]))
    });
});

module.exports = router;
